package cn.com.open.itembank.service;

import cn.com.open.itembank.dto.ReturnModel;
import cn.com.open.itembank.dto.RuleInputModel;
import cn.com.open.itembank.dto.RulesSearchModel;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;

/**
 * 策略
 */
@FeignClient(name = "item-paper-service")
public interface ItemBankRulesRemoteService {


    //region 策略删除

    /**
     * 策略删除
     *
     * @param appKey     the app key
     * @param itemBankId the item bank id
     * @param id         the id
     * @return return model
     */
    @DeleteMapping(value = "/itembank/{itemBankId}/rules/{id}")
    ReturnModel removeRules(@RequestParam("appKey") String appKey,
                            @PathVariable(value = "itemBankId") String itemBankId,
                            @PathVariable(value = "id") String id);
    //endregion

    //region 策略状态修改

    /**
     * 策略状态修改
     *
     * @param appKey     the app key
     * @param itemBankId the item bank id
     * @param id         the id
     * @return return model
     */
    @PutMapping(value = "/itembank/{itemBankId}/rules/{id}/status")
    ReturnModel updateRulesStatus(@RequestParam("appKey") String appKey,
                                  @PathVariable(value = "itemBankId") String itemBankId,
                                  @PathVariable(value = "id") String id);
    //endregion

    //region 策略修改

    /**
     * 策略修改
     *
     * @param appKey         the app key
     * @param itemBankId     the item bank id
     * @param ruleInputModel the ruleInputModel
     * @return return model
     */
    @PutMapping(value = "/itembank/{itemBankId}/rules/update")
    ReturnModel updateRules(@RequestParam("appKey") String appKey,
                            @PathVariable(value = "itemBankId") String itemBankId,
                            @RequestBody RuleInputModel ruleInputModel);
    //endregion

    //region 获取策略信息

    /**
     * 获取策略信息
     *
     * @param appKey     the app key
     * @param itemBankId the item bank id
     * @param id         策略id
     * @return return model
     */
    @GetMapping(value = "/itembank/{itemBankId}/rules/{id}")
    ReturnModel getRuleInfo(@RequestParam("appKey") String appKey,
                            @PathVariable(value = "itemBankId") String itemBankId,
                            @PathVariable(value = "id") String id);
    //endregion

    //region 策略添加

    /**
     * 策略添加
     *
     * @param appKey         the app key
     * @param itemBankId     the item bank id
     * @param ruleInputModel 策略ruleInputModel
     * @return return model
     */
    @PostMapping(value = "/itembank/{itemBankId}/rules")
    ReturnModel addRules(@RequestParam("appKey") String appKey,
                         @PathVariable(value = "itemBankId") String itemBankId,
                         @RequestBody RuleInputModel ruleInputModel);
    //endregion

    //region 获取策略列表

    /**
     * 获取策略列表
     *
     * @param appKey           the app key
     * @param itemBankId       the item bank id
     * @param rulesSearchModel 策略模型
     * @return return model
     */
    @PostMapping(value = "/itembank/{itemBankId}/getruleslist")
    ReturnModel getRulesList(@RequestParam("appKey") String appKey,
                             @PathVariable(value = "itemBankId") String itemBankId,
                             @RequestBody RulesSearchModel rulesSearchModel);

    //endregion

    //region 同步组卷

    /**
     * 同步组卷
     *
     * @param appKey     AppKey
     * @param itemBankId 题库ID
     * @param ruleID     策略id
     * @param paperCount 组卷数量
     * @param paperName  试卷名称
     * @return return model
     */
    @PostMapping(value = "/itembank/{itemBankId}/rules/{ruleID}/createtestpaper")
    ReturnModel createTestPaper(@RequestParam("appKey") String appKey,
                                @PathVariable(value = "itemBankId") String itemBankId,
                                @PathVariable(value = "ruleID") String ruleID,
                                @RequestParam("paperCount") int paperCount,
                                @RequestParam("paperName") String paperName);
    //endregion

    //region 异步组卷

    /**
     * 异步组卷
     *
     * @param appKey     AppKey
     * @param itemBankId 题库ID
     * @param ruleID     策略id
     * @param paperCount 组卷数量
     * @param paperName  试卷名称
     * @param backUrl    回调路径
     * @return return model
     */
    @PostMapping(value = "/itembank/{itemBankId}/rules/{ruleID}/asynccreatetestpaper")
    ReturnModel asyncGenerateCreateTestPaper(@RequestParam("appKey") String appKey,
                                             @PathVariable(value = "itemBankId") String itemBankId,
                                             @PathVariable(value = "ruleID") String ruleID,
                                             @RequestParam("paperCount") int paperCount,
                                             @RequestParam("paperName") String paperName,
                                             @RequestParam("backUrl") String backUrl) throws UnsupportedEncodingException;
    //endregion

}
